﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PeerNetwork.PacketHandler
{
    public class PackageCreator
    {


        public static PackageHandler getPackage(string type, PackageContainer container)
        {
            PackageHandler packet = null;

            try
            {
                switch (type.ToUpper())
                {
                    case ("CHAT"):
                        packet = new ChatPackage(container.to, container.from, container.message);
                        return packet;

                    case ("WALLPOST"):
                        packet = new WallpostPackage(container.to, container.from, container.message);
                        return packet;

                    case ("LINK"):
                        packet = new LinkPackage(container.to, container.from, container.message);
                        return packet;

                    case ("COMMENT"):
                        packet = new CommentPackage(container.to, container.from, container.message);
                        return packet;

                    default:
                        return null;

                }
            }
            catch (ArgumentNullException exception)
            {

                Console.WriteLine(exception.Message);

            }
            return null;
        }

        public static PackageHandler getPackage(string type, string from, string to, string message)
        {
            PackageHandler packet = null;

            try
            {
                switch (type.ToUpper())
                {
                    case ("CHAT"):
                        packet = new ChatPackage(from, to, message);
                        return packet;

                    case ("WALLPOST"):
                        packet = new WallpostPackage(from, to, message);
                        return packet;

                    case ("LINK"):
                        packet = new LinkPackage(from, to, message);
                        return packet;

                    case ("COMMENT"):
                        packet = new CommentPackage(from, to, message);
                        return packet;

                    default:
                        return null;

                }
            }
            catch(ArgumentNullException exception){

                Console.WriteLine(exception.Message);

            }
            return null;
        }
    }

    

       
    
}
